package in.muton.edushare.jquery;

import in.muton.edushare.panels.ImageHolder;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.list.ListView;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.Model;

public class CarouselContainer extends Panel {
	private static final long serialVersionUID = -4287064485491259950L;

	private List<CarouselListItem> panelList = new ArrayList<CarouselListItem>();
	
	public CarouselContainer(String id) {
		super(id);
		add(new ListView<CarouselListItem>("carouselItemList",panelList){
			private static final long serialVersionUID = 2637378548863175034L;
			@Override
			protected void populateItem(ListItem<CarouselListItem> arg0) {
				CarouselListItem c = arg0.getModelObject();
				arg0.add(new ImageHolder("carouselItemImage",new Model<String>(c.imgSrc)));
				arg0.add(new Label("carouselItemText",c.title));
			}
		});
	}
	public String getNextId(){
		return "carouselItemText";
	}
	
	public void addCarouselItem(String imgSrc, String title){
		panelList.add(new CarouselListItem(imgSrc, title));
	}
	
	public class CarouselListItem implements Serializable{
		private static final long serialVersionUID = 4898432858817107326L;
		private String imgSrc;
		private String title;
		public CarouselListItem(String imgSrc, String title) {
			super();
			this.imgSrc = imgSrc;
			this.title = title;
		}

		public String getImgSrc() {
			return imgSrc;
		}

		public String getTitle() {
			return title;
		}
	}
	
}
